package com.example.campuslink.ui.activity.ai

import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.example.campuslink.BR
import com.example.campuslink.R
import com.example.campuslink.commen.tools.putExtraKey
import com.example.campuslink.databinding.ActivityAiDetailBinding
import com.example.campuslink.model.DeepSeekTalkData
import com.example.campuslink.ui.activity.BaseActivity
import com.example.campuslink.viewModel.ai.InquiriesViewModel

class AiDetailActivity : BaseActivity<ActivityAiDetailBinding, InquiriesViewModel>(
    InquiriesViewModel::class.java,
    R.layout.activity_ai_detail,
    BR.viewModel
) {
    override fun initView() {
        mViewModel?.context = this
        mViewModel?.initDB(this)
        mViewModel?.getUserInfoTable()
        val deepSeekTalkData =
            intent.getSerializableExtra(putExtraKey.AI_TALK_DATA.key) as DeepSeekTalkData
        mViewModel?.userInfo?.observe(this) {
            Glide.with(this).load(mViewModel?.userInfo?.value?.userAvatar)
                .error(R.drawable.ic_empty)
                .apply(RequestOptions.circleCropTransform())
                .into(mViewDataBinding?.ivUserImg!!)
        }
        mViewDataBinding?.tvUserAsk?.text = deepSeekTalkData.problem
        mViewDataBinding?.tvThink?.text = deepSeekTalkData.aiThink
        mViewDataBinding?.tvAnswer?.text = deepSeekTalkData.aiAsk
        mViewDataBinding?.ivBack?.setOnClickListener({
            finish()
        })
    }
}